<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>用户信息详情页</title>
		<meta name="viewport" content="initial-scale=1, maximum-scale=1">
		<link rel="shortcut icon" href="/static/favicon.ico">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="/static/css/sm.min.css">
		<link rel="stylesheet" href="/static/css/sm-extend.min.css">
	</head>

	<body>

		<header class="bar bar-nav">
			<a class="icon icon-left pull-left" href="/page/setting"></a>
			<a class="icon icon-refresh pull-right"></a>
			<h1 class="title">用户信息修改</h1>
		</header>
		<div class="content">
			<div class="list-block">
				<input type="hidden" id="id" name="userId">
				<ul>
					<!-- Text inputs -->
					<!--<li>-->
						<!--<div class="item-content">-->
							<!--<div class="item-media"><i class="icon icon-form-name"></i></div>-->
							<!--<div class="item-inner">-->
								<!--<div class="item-title label">userId</div>-->
								<!--<div class="item-input">-->
									<!--<input type="text" name="id" type="hidden">-->
								<!--</div>-->
							<!--</div>-->
						<!--</div>-->
					<!--</li>-->
					<li>
						<div class="item-content">
							<div class="item-media"><i class="icon icon-form-name"></i></div>
							<div class="item-inner">
								<div class="item-title label">姓名</div>
								<div class="item-input">
									<input type="text" name="username">
								</div>
							</div>
						</div>
					</li>

					<li>
						<div class="item-content">
							<div class="item-media"><i class="icon icon-form-name"></i></div>
							<div class="item-inner">
								<div class="item-title label">登录名</div>
								<div class="item-input">
									<input type="text" name="loginname">
								</div>
							</div>
						</div>
					</li>

					<li>
						<div class="item-content">
							<div class="item-media"><i class="icon icon-form-email"></i></div>
							<div class="item-inner">
								<div class="item-title label">邮箱</div>
								<div class="item-input">
									<input type="email" name="email">
								</div>
							</div>
						</div>
					</li>

					<li>
						<div class="item-content">
							<div class="item-media"><i class="icon icon-form-email"></i></div>
							<div class="item-inner">
								<div class="item-title label">电话号码</div>
								<div class="item-input">
									<input type="number" name="phone">
								</div>
							</div>
						</div>
					</li>


					<li>
						<div class="item-content">
							<div class="item-media"><i class="icon icon-form-gender"></i></div>
							<div class="item-inner">
								<div class="item-title label">性别</div>
								<div class="item-input">
									<select>
										<option value="1">男</option>
										<option value="0">女</option>
									</select>
								</div>
							</div>
						</div>
					</li>
				</ul>
			</div>
			<div class="content-block">
				<div class="row">
					<div class="col-50">
						<a href="#"  class="button button-big button-fill button-danger">取消</a>
					</div>
					<div class="col-50">
						<a href="#" onclick="update()" class="button button-big button-fill button-success">提交</a>
					</div>
				</div>
			</div>
		</div>

		<script type='text/javascript' src='/static/lib/zepto/zepto.min.js' charset='utf-8'></script>
		<script type='text/javascript' src='/static/js/sm.min.js' charset='utf-8'></script>
		<script type='text/javascript' src='/static/js/sm-extend.min.js' charset='utf-8'></script>


		<script>
            $(function () {
                $.ajax({
                    type : "post",
                    url  : "/sys/user/getLoginInfo",
                    dataType : "json",
                    success : function (re) {
                        var result = re;
                        if (result.status == 0){
                            $("input[name= 'userId']").val(result.data.userId);
                            $("input[name = username]").val(result.data.username);
                            $("input[name = loginname]").val(result.data.loginname);
                            $("input[name = email]").val(result.data.email);
                            $("input[name = phone]").val(result.data.phone);
                            // $('#sex option').val(result.data.sex);
                        } else {
                            window.location.href = '/page/loginUI'
                        }
                    }
                })
            });

            function update() {
                var userId = $("input[name = 'userId']").val();
				var username = $("input[name = 'username']").val().trim();
                var loginName = $("input[name='loginname']").val().trim();
                var email = $("input[name ='email' ]").val().trim();
                var phone = $("input[name = 'phone']").val().trim();
                var sex = $('#sex option').val();
                $.ajax({
					type : "post",
					url  : "/sys/user/update",
					dataType : "json",
					data : {
					    "userId":userId,
                        "username":username,
                        "loginname":loginName,
                        "email":email,
                        "phone":phone,
                        "sex":sex
					},
					success : function (re) {
						var result = re;
						if (result.status === 0){
						    alert(result.msg);
						} else {
						    alert(result.msg);
						}
                    }
				})
            }
		</script>
	</body>

</html>